#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "filepreview.h"

#include <QFileDialog>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushbutton_openfile_clicked()
{
    QString fileurl = QFileDialog::getOpenFileName(this,
                        "选择你要打开的文件", "/home/zhou", "*txt");
    if(fileurl.isEmpty())
    {
        QMessageBox::warning(this, "警告", "您没有选择文件");
        return;
    }
    QString info = QString("您选择的文件是%1").arg(fileurl);
    QMessageBox::information(this, "文件选择成功", info);
    filepreview *fp = new filepreview(fileurl, this);
    fp->show();
    this->hide();
}

